home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / favour1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-22  |  7.7 KB  |  212 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmHistory 
  4.    Caption         =   "Favourites  Manager"
  5.    ClientHeight    =   3480
  6.    ClientLeft      =   3720
  7.    ClientTop       =   2490
  8.    ClientWidth     =   6000
  9.    ForeColor       =   &H00400040&
  10.    Icon            =   "Form1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   3480
  14.    ScaleWidth      =   6000
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdReload 
  17.       Caption         =   "Reload"
  18.       Height          =   375
  19.       Left            =   4440
  20.       TabIndex        =   4
  21.       ToolTipText     =   "Reload Favorites"
  22.       Top             =   1680
  23.       Width           =   1335
  24.    End
  25.    Begin VB.TextBox txtShow 
  26.       Enabled         =   0   'False
  27.       Height          =   375
  28.       Left            =   3390
  29.       Locked          =   -1  'True
  30.       TabIndex        =   6
  31.       TabStop         =   0   'False
  32.       ToolTipText     =   "LOCKED"
  33.       Top             =   2700
  34.       Width           =   2415
  35.    End
  36.    Begin VB.CommandButton cmdDelete 
  37.       Caption         =   "Delete"
  38.       Height          =   375
  39.       Left            =   4440
  40.       TabIndex        =   3
  41.       ToolTipText     =   "Delete a Favorite"
  42.       Top             =   1200
  43.       Width           =   1335
  44.    End
  45.    Begin VB.TextBox txtAdd 
  46.       Height          =   375
  47.       Left            =   3390
  48.       TabIndex        =   5
  49.       ToolTipText     =   "Type Favorite to Add in Here"
  50.       Top             =   2205
  51.       Width           =   2415
  52.    End
  53.    Begin VB.CommandButton cmdSave 
  54.       Caption         =   "Save"
  55.       Height          =   375
  56.       Left            =   4440
  57.       TabIndex        =   2
  58.       ToolTipText     =   "Save Favorites"
  59.       Top             =   720
  60.       Width           =   1335
  61.    End
  62.    Begin VB.CommandButton cmdAdd 
  63.       Caption         =   "Add"
  64.       Height          =   375
  65.       Left            =   4440
  66.       TabIndex        =   1
  67.       ToolTipText     =   "Add a Favorite"
  68.       Top             =   240
  69.       Width           =   1335
  70.    End
  71.    Begin MSComctlLib.ListView lvFav 
  72.       Height          =   3255
  73.       Left            =   120
  74.       TabIndex        =   0
  75.       TabStop         =   0   'False
  76.       ToolTipText     =   "Favorites List"
  77.       Top             =   120
  78.       Width           =   3165
  79.       _ExtentX        =   5583
  80.       _ExtentY        =   5741
  81.       View            =   3
  82.       Arrange         =   1
  83.       Sorted          =   -1  'True
  84.       MultiSelect     =   -1  'True
  85.       LabelWrap       =   -1  'True
  86.       HideSelection   =   -1  'True
  87.       AllowReorder    =   -1  'True
  88.       FlatScrollBar   =   -1  'True
  89.       FullRowSelect   =   -1  'True
  90.       GridLines       =   -1  'True
  91.       HotTracking     =   -1  'True
  92.       HoverSelection  =   -1  'True
  93.       _Version        =   393217
  94.       ForeColor       =   255
  95.       BackColor       =   3199960
  96.       BorderStyle     =   1
  97.       Appearance      =   1
  98.       NumItems        =   1
  99.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  100.          Text            =   "Sites"
  101.          Object.Width           =   5380
  102.       EndProperty
  103.    End
  104. Attribute VB_Name = "frmHistory"
  105. Attribute VB_GlobalNameSpace = False
  106. Attribute VB_Creatable = False
  107. Attribute VB_PredeclaredId = True
  108. Attribute VB_Exposed = False
  109. '##################################################
  110. '#            Code by Andy McCurtin               #
  111. '#  You may use this code freely in any of your   #
  112. '#  programs I would however appreiciate it if    #
  113. '#  you improve this code in any way that you     #
  114. '#  send me a copy of the update code             #
  115. '#                                                #
  116. '#          e-mail : moon_2@hotmail.com           #
  117. '#                                                #
  118. '#                Happy Programming               #
  119. '##################################################
  120. Option Explicit
  121. '############### Global Variable Declarations #####
  122. Dim a() As String
  123. Dim i As Integer
  124. Dim ItemCount
  125. '##################################################
  126. Private Sub CmdAdd_Click()
  127. Dim itm As ListItem     'set itm as lvFav.listitem
  128. If txtAdd.Text = "" Then     'if txtAdd has nothing in it diplay msgbox
  129.     MsgBox "Please enter something to add", vbInformation, "Favourites  Manager"
  130. Else    'otherwise add the text in txtAdd to lvFav
  131.       Set itm = lvFav.ListItems.Add(, , txtAdd.Text)
  132. End If
  133. txtAdd.Text = "" 'clear txtAdd
  134. End Sub
  135. Private Sub cmdDelete_Click()
  136. 'if the list count is 0 and no items are selected
  137. 'or selected item is index 1 display msgbox
  138. If Not lvFav.ListItems.Count = 0 And Not lvFav.SelectedItem.Selected Or lvFav.SelectedItem.Index = 1 Then
  139. MsgBox "Nothing to delete", vbInformation, "Favourites  Manager"
  140. Else    'otherwise remove selected item
  141. lvFav.ListItems.Remove lvFav.SelectedItem.Index
  142. End If
  143. cmdReload.Enabled = True    're-enable cmdReload
  144. End Sub
  145. Private Sub cmdReload_Click()
  146. '######## Declare loacal variables ##############
  147. Dim itm As ListItem     'set itm as lvFav.listitem
  148. Dim a As String     'set a as a string
  149. Dim b As String     'set b as a string
  150. '################################################
  151.  lvFav.ListItems.Clear     'clear contents of lvFav to
  152.                         'prevent over writing files
  153. b = "Select an item from below"    'set b as text
  154. Set itm = lvFav.ListItems.Add(, , b)   'add b to lvFav
  155. '####### Opens & loads text file into lvFav #########
  156.     Open App.Path & "\Favourites .txt" For Input As #1
  157.     Do Until EOF(1)
  158.     Input #1, a
  159.               Set itm = lvFav.ListItems.Add(, , a)
  160.     Loop
  161.     Close #1
  162. '################################################
  163. cmdReload.Enabled = False       're-enable cmdReload
  164. End Sub
  165. Private Sub CmdSave_Click()
  166. 'set itemcount as lvFav.listitems.count
  167. ItemCount = frmHistory.lvFav.ListItems.Count
  168. For i = 2 To ItemCount      'load from index 2 to total
  169.     ReDim Preserve a(i) As String
  170.     a(i) = frmHistory.lvFav.ListItems(i).Text   'set a as lvFav.listitems text i.e. www.microsoft.com
  171.     Next i      'load next item
  172.         
  173. '######### opens file for appending ###############
  174.     Open App.Path & "\Favourites .txt" For Output As #1
  175.     For i = 2 To ItemCount
  176.         Write #1, a(i)
  177.         Next i
  178.         Close #1
  179. '##################################################
  180. cmdReload.Enabled = True        're-enable cmdReload
  181. End Sub
  182. Private Sub Form_Load()
  183. '######## Declare loacal variables ##############
  184. Dim itm As ListItem     'set itm as lvFavFav.listitem
  185. Dim a As String     'set a as a string
  186. Dim b As String     'set b as a string
  187. '################################################
  188.  lvFav.ListItems.Clear     'clear contents of lvFavFav to
  189.                         'prevent over writing files
  190. b = "Select an item from below"    'set b as text
  191. Set itm = lvFav.ListItems.Add(, , b)   'add b to lvFav
  192. '####### Opens & loads text file into lvFav #########
  193.     Open App.Path & "\Favourites .txt" For Input As #1
  194.     Do Until EOF(1)
  195.     Input #1, a
  196.               Set itm = lvFav.ListItems.Add(, , a)
  197.     Loop
  198.     Close #1
  199. '################################################
  200. End Sub
  201. Private Sub lvFav_Click()
  202. If lvFav.ListItems.Count = 0 Then 'if no items to select then display msgbox
  203. MsgBox "No items to select", vbInformation, "Favourites  Manager"
  204. Else    'otherwise set txtShow.text as lvFav.items text this can be used to tranfer to combobox for
  205.         'URL browsing
  206. txtShow.Text = lvFav.SelectedItem
  207. End If
  208. End Sub
  209. Private Sub lvFav_LostFocus()
  210. txtShow.Text = "" 'when lvFav loses focus clear txtShow
  211. End Sub
  212.